<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Giỏ Hàng</title>
    </h:head>
    <h:body>
        <table width="746" border="1" cellspacing="0" cellpadding="0">


            <c:if test="#{GioHang.getGioHang().size()!=0}" >       
                <td bgcolor="#FFFF8F">
                    <h:form >  
                        <c:if test="${login.gettaikhoan()!=null}">
                            <h:commandButton action="#{page.setpage('ThanhToan')}" value ="Thanh Toán" />
                        </c:if>
                        <c:if test="${login.gettaikhoan()==null}">
                            <h:outputText value="Bạn cần đăng nhập để thanh toan"/>
                        </c:if>
                    </h:form>    </td>
              
                <c:forEach var="i" begin="1" end="${GioHang.getGioHang().size()}">
                    <tr>
                        #{GioHang.setvt(i-1)}
                        <c:set var="record" value="${GioHang.getGioHang().get(i-1)}"/> 
                      
                            <td>
                                
                                <h:commandLink action="#{detailmobile.setThongtin1sanpham(record.getmadt())}">
                                    <h:graphicImage library="images" name="${record.gethinh()}" height="186" width="186"/>
                                </h:commandLink>
                                
                            </td>
                       
                        <td>
                            <h:outputText value="${record.tenDT}"/> <br/>
                        </td>
                        <td>
                            <h:outputText value="${record.gia}">
                                <f:convertNumber type="currency"  currencyCode="VND" groupingUsed="true"  maxFractionDigits="0"/> 
                            </h:outputText>
                            <br/>
                        </td>                       
                        <td bgcolor="#FFFF8F">
                            
                                 <h:inputText value="#{GioHang.sl}"/>                                
                                <h:commandButton value="Update" action="#{GioHang.setUpdateSoLuong()}">                                
                                </h:commandButton>
                              
                        </td>
                        <p>&nbsp;</p> <td bgcolor="#FFFF8F">                         
                            
                           <h:commandButton value="Xoá" action="#{GioHang.setDeleteHangTrongGio()}" actionListener="#{GioHang.attrListener}">
                                    <f:attribute value="${i-1}" name="vitri"/>
                                </h:commandButton>
                           
                        </td>  

                    </tr>
                </c:forEach>
                
            </c:if>

            <c:if test="#{GioHang.getGioHang().size()==0}" >       
                <h:outputText value="Giỏ Hàng Của Bạn Trống." />
            </c:if>
        </table>

    </h:body>
</html>

